package cn.gary.oaserver.service.impl;

import cn.gary.oaserver.entity.TAdminRole;
import cn.gary.oaserver.entity.vo.AdminRoleVO;
import cn.gary.oaserver.mapper.TAdminRoleMapper;
import cn.gary.oaserver.service.ITAdminRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author gary
 * @since 2024-03-15
 */
@Service
public class TAdminRoleServiceImpl extends ServiceImpl<TAdminRoleMapper, TAdminRole> implements ITAdminRoleService {

    @Override
    @Transactional
    public boolean addListAdminRole(AdminRoleVO adminRoleVO) {
        boolean flag = false;
        baseMapper.deleteById ( adminRoleVO.getAdminId () );
        for (Integer rid : adminRoleVO.getRid ( )) {
            flag=true;
            baseMapper.insert ( new TAdminRole (adminRoleVO.getAdminId (),rid) );
        }
        return flag;
    }
}
